<?php

class ShopcpModule {
    
    public function bzj() {
        global $_FANWE;
        
        if($_POST['dobzj']) {
            $arr = array(0.01, 1000, 3000, 5000, 10000, 20000, 50000, 100000, 200000, 500000);
            if(!in_array($_POST['bzj'], $arr))
                exit;
            
            $total_fee = $_POST['bzj'];
            $orderid = date('Ymdhis');
            $ordername = '火锅阁'.$_POST['bzj'].'元保证金订单';
            FDB::insert('wogu_order_bzj', array(
                'orderid' => $orderid,
                'ordername' => $ordername,
                'userid' => $_FANWE['uid'],
                'total_fee' => $total_fee,
                'dateline' => time()
            ));
    
            require_once(FANWE_ROOT . 'payment/alipay.php');
            $aliapy_config = include(FANWE_ROOT . 'payment/alipay_config_bzj.php');
            
            //构造要请求的参数数组
            $parameter = array(
                'service'            => 'create_direct_pay_by_user',
                'payment_type'        => '1',
                'partner'            => $aliapy_config['partner'],
                '_input_charset'    => $aliapy_config['input_charset'],
                'seller_email'        => $aliapy_config['seller_email'],
                'return_url'        => $aliapy_config['return_url'],
                'notify_url'        => $aliapy_config['notify_url'],
                'out_trade_no'        => $orderid,
                'subject'            => $ordername,
                'body'                => $ordername,
                'total_fee'            => $total_fee
            );
    
            //构造即时到帐接口
            $alipayService = new AlipayService($aliapy_config);
            $html_text = $alipayService->create_direct_pay_by_user($parameter);
            include template('page/article/article_dopayment');
            display();
            exit;
        }

        $sql = 'SELECT * FROM '.FDB::table('wogu_user_shop').' WHERE uid='.$_FANWE['user']['uid'];
        $shopinfo = FDB::fetchFirst($sql);
        include template('page/shopcp/bzj');
        display();
    }
}
